package com.inmobi.commons.thinICE.wifi;

import android.content.Context;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import com.inmobi.commons.thinICE.icedatacollector.IceDataCollector;
import com.inmobi.commons.thinICE.icedatacollector.ThinICEConfigSettings;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public final class WifiUtil
{
  private static final String[] a = { "android.permission.ACCESS_WIFI_STATE" };
  private static final String[] b = { "android.permission.ACCESS_WIFI_STATE", "android.permission.CHANGE_WIFI_STATE" };
  private static final String[] c = { "android.permission.WAKE_LOCK" };

  private static long a(byte paramByte)
  {
    return 0xFF & paramByte;
  }

  private static long a(byte[] paramArrayOfByte)
  {
    long l = 0L;
    if ((paramArrayOfByte != null) && (paramArrayOfByte.length == 6))
      l = a(paramArrayOfByte[5]) | a(paramArrayOfByte[4]) << 8 | a(paramArrayOfByte[3]) << 16 | a(paramArrayOfByte[2]) << 24 | a(paramArrayOfByte[1]) << 32 | a(paramArrayOfByte[0]) << 40;
    return l;
  }

  private static boolean a(boolean paramBoolean, String paramString)
  {
    return (paramBoolean) && (paramString != null) && (paramString.endsWith("_nomap"));
  }

  public static WifiInfo getConnectedWifiInfo(Context paramContext)
  {
    int i = IceDataCollector.getConfig().getWifiFlags();
    if (!ThinICEConfigSettings.bitTest(i, 2));
    for (boolean bool = true; ; bool = false)
      return getConnectedWifiInfo(paramContext, bool, ThinICEConfigSettings.bitTest(i, 1));
  }

  public static WifiInfo getConnectedWifiInfo(Context paramContext, boolean paramBoolean1, boolean paramBoolean2)
  {
    android.net.wifi.WifiInfo localWifiInfo = ((WifiManager)paramContext.getSystemService("wifi")).getConnectionInfo();
    if (localWifiInfo == null);
    WifiInfo localWifiInfo1;
    String str1;
    String str2;
    do
    {
      return null;
      localWifiInfo1 = new WifiInfo();
      str1 = localWifiInfo.getBSSID();
      str2 = localWifiInfo.getSSID();
    }
    while ((str1 == null) || (a(paramBoolean1, str2)));
    localWifiInfo1.bssid = macToLong(str1);
    if (paramBoolean2)
      str2 = null;
    localWifiInfo1.ssid = str2;
    localWifiInfo1.rssi = localWifiInfo.getRssi();
    localWifiInfo1.ip = localWifiInfo.getIpAddress();
    return localWifiInfo1;
  }

  public static boolean hasGetConnectedWifiInfoPermission(Context paramContext)
  {
    String[] arrayOfString = a;
    int i = arrayOfString.length;
    for (int j = 0; j < i; j++)
      if (paramContext.checkCallingOrSelfPermission(arrayOfString[j]) != 0)
        return false;
    return true;
  }

  public static boolean hasWifiScanPermission(Context paramContext, boolean paramBoolean)
  {
    String[] arrayOfString1 = b;
    int i = arrayOfString1.length;
    for (int j = 0; j < i; j++)
      if (paramContext.checkCallingOrSelfPermission(arrayOfString1[j]) != 0)
        return false;
    if (paramBoolean)
    {
      String[] arrayOfString2 = c;
      int k = arrayOfString2.length;
      for (int m = 0; ; m++)
      {
        if (m >= k)
          break label77;
        if (paramContext.checkCallingOrSelfPermission(arrayOfString2[m]) != 0)
          break;
      }
    }
    label77: return true;
  }

  public static long macToLong(String paramString)
  {
    String[] arrayOfString = paramString.split("\\:");
    byte[] arrayOfByte = new byte[6];
    for (int i = 0; i < 6; i++)
      arrayOfByte[i] = ((byte)Integer.parseInt(arrayOfString[i], 16));
    return a(arrayOfByte);
  }

  public static WifiInfo scanResultToWifiInfo(ScanResult paramScanResult, boolean paramBoolean)
  {
    if (paramScanResult == null)
      return null;
    WifiInfo localWifiInfo = new WifiInfo();
    localWifiInfo.bssid = macToLong(paramScanResult.BSSID);
    String str = null;
    if (paramBoolean);
    while (true)
    {
      localWifiInfo.ssid = str;
      localWifiInfo.rssi = paramScanResult.level;
      return localWifiInfo;
      str = paramScanResult.SSID;
    }
  }

  public static List<WifiInfo> scanResultsToWifiInfos(List<ScanResult> paramList, boolean paramBoolean1, boolean paramBoolean2)
  {
    if (paramList == null)
      return null;
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator = paramList.iterator();
    while (localIterator.hasNext())
    {
      ScanResult localScanResult = (ScanResult)localIterator.next();
      if (!a(paramBoolean1, localScanResult.SSID))
        localArrayList.add(scanResultToWifiInfo(localScanResult, paramBoolean2));
    }
    return localArrayList;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.inmobi.commons.thinICE.wifi.WifiUtil
 * JD-Core Version:    0.6.2
 */